#include <chrono>
#include <iostream>
#include <thread>

#include "p0.h"
#include "p1.h"
#include "p2.h"
#include "p4.h"
#include "p5.h"
#include "p6.h"
#include "po.h"
#include "p7.h"
#include "p8.h"
#include "p9.h"
#include "p10.h"
#include "p11.h"
#include "p12.h"
#include "p13.h"
#include "p14.h"
#include "p15.h"
#include "p16.h"
#include "timer.h"


void timeConsumptionTest() {
    Timer timer;
    timer.start(); // Start timing

    // Simulate some work
    std::this_thread::sleep_for(std::chrono::milliseconds(20));

    long long duration = timer.elapsedMilliseconds(); // Get elapsed time
    std::cout << "Duration: " << duration << " milliseconds" << std::endl;
}

int main() {
    printSupportCppVersion();

    int testChapterId = 16;

    if (testChapterId == 1) {
        testHomeWork();
        testOperatorAndLiteral();
        myFirstFunc();
        addAndSubstract();
    } else if (testChapterId == 2) {
        testHomeWork2_4();
    } else if (testChapterId == 4) {
        testHomeWork4_10();
        testHomeWork4_12();
        testHomeWork4_x();
        testHomeWork4_x2();
    } else if (testChapterId == 5) {
        testDiffDigital();
        funcTestNVRO();   // 这里会触发RVO，这样就不会看到"Copied" log了
        testInlineFunc();
        testHomeWork6();
    } else if (testChapterId == 6) {
        testHomeWork6_01();
        testHomeWork6_03();
    } else if (testChapterId == -1) {
        // po.cpp
        testBitset();
        testBitwiseOperator();
        // getRgbaValue();
        printUint8DigitalUseBinFmt();
    } else if (testChapterId == 7) {
        testHomeWork7_02();
        testHomeWork7_03();
    } else if (testChapterId == 8) {
        testHomeWork8_08();
        // testRandom();
        BallHeight::testBallHeight();
        IsPrime::testPrimeList();
        GuessNumber::playGame();
    } else if (testChapterId == 9) {
        testStaticAssert();
    } else if (testChapterId == 10) {
        testHomeWorkP10_07();
        testFuncPtrArray();
        myCallbackTest();
    } else if (testChapterId == 11) {
        testHomeWork11_09();
        testHomeWork11_q2();
        testHomeWork11_q3();
        testHomeWork11_q4();
        testHomeWork11_last();
    } else if (testChapterId == 12) {
        testNULL();
        testMaxRef();
    } else if (testChapterId == 13) {
        std::cout << toAsciiLowerCase("Hello DA SA BI") << '\n';
        testToAsciiLowerCaseNew();
        testColorStdOut();
        testHomeWork13_13();
        testAnimalLegs();
        testHomeWorkLast_01();
        testHomeWorkLast_03();
    } else if (testChapterId == 14) {
        testHomeWork14_4();
        testConstHomeWork14_5();
        testHomeWork14_10();
        testHomeWork14_16();
        testHomeWork14_17();
    } else if (testChapterId == 15) {
        // HOMEWORK_P15::testThisPtr();
        // HOMEWORK_P15::testResetThisInstance();
        // HOMEWORK_P15::test_chap_15_3();
        // HOMEWORK_P15::test_chap_15_4();
        // HOMEWORK_P15::test_chap_15_5();
        // HOMEWORK_P15::test_chap_15_6();
        // HOMEWORK_P15::test_chap_15_7();
        // HOMEWORK_P15::test_chap_15_8();
        // HOMEWORK_P15::test_chap_15_9();
        // HOMEWORK_P15::test_chap_15_9_homework();
        // HOMEWORK_P15_9_2::test_chap_15_9_homework();
        // HOMEWORK_P15_10::test_reference();
        HOMEWORK_P15_SUMMARY_TEST::test();
    } else if (testChapterId == 16) {
        // CourseP16::test_p16_2();
        // CourseP16::homework_01();
        // CourseP16::homework_02();
        // CourseP16::homework_03();
        // CourseP16::homework_04();
        // CourseP16::course_16_4();
        // CourseP16::homework_16_4();
        // CourseP16::course_16_5();
        // CourseP16::course_16_5_add();
        // CourseP16::homework_16_6();
        // CourseP16::course_16_7();
        // CourseP16::homework_16_8_1();
        CourseP16::homework_16_8_2();
    }

    return 0;
}
